package 面试常见刷题;

import java.util.Arrays;

public class 插入排序 {
    public static void main(String[] args) {
        int[] ints = {1, 213, 12, 31, 41, 12};
        insertSort(ints);
        System.out.println(Arrays.toString(ints));
    }
    public static void insertSort(int[] data){
        for (int i = 1; i < data.length; i++) {
            for (int j = i-1; j>=0; j--) {
                if(data[j]>data[j+1]){
                    工具类.swap(data,j,j+1);
                }else {
                    break;
                }
            }
        }
    }
}
